<template>
	<view>

		<view class=" ">
			<view class="p-10 bg-white">
				<view class="banmi_flex a-c p-10">
					<view class="f-16">
						名称：
					</view>
					<uni-easyinput v-model="find.name" placeholder="名称">
					</uni-easyinput>
				</view>
				<view class="p-20" style="width: 96.7%;" v-if="is_true">
					<mosoweEditor @change="on_ok" :content="content" :height="500" :placeholder="placeholder"
						:mode="mode">
					</mosoweEditor>
				</view>
				<view class="" style="height: 40px;">
				</view>

				<view>
					<view class="">
						<button @click="on_set_platform" style="width: 200px;">
							保存
						</button>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import mosoweEditor from '@/components/editor/editor.vue'
	export default {
		components: {
			mosoweEditor,
		},
		props: {

			article_id: {
				type: Number | String,
				default: 1
			},

			version: {
				type: String,
				default: ''
			},

			list_goods: {
				type: Array,
				default: function() {
					return [] //数据
				}
			}
		},
		data() {
			return {
				codetime: 8,
				find: {},
				name: '',
				keya: '',
				is_true: false,
				content: '',
				placeholder: '请输入内容...',
				mode: 'default', // or 'simple'
			};
		},

		mounted() {
			this.init();

		},
		methods: {
			onDestroyed(editor) {
				console.log('onDestroyed', editor)
			},
			onMaxLength(editor) {
				console.log('onMaxLength', editor)
			},
			onFocus(editor) {
				console.log('onFocus', editor)
			},
			onBlur(editor) {
				console.log('onBlur', editor)
			},
			customPaste(editor, event, callback) {},
			on_ok(val) {
				this.content = val;
			},
			async on_set_platform() {
				var url = this.img_url;
				this.content = this.content.replace(new RegExp(url, 'g'), "");

				let requestParams = {
					id: this.article_id,
					content: this.content,
					name: this.find.name
				};

				const ret = await this.Banmikeji.Settings_set_article_edit(requestParams);
				uni.showToast({
					title: ret.msg,
					icon: 'none'
				})

			},
			async init() {
				let requestParams = {
					id: this.article_id,
				};
				const ret = await this.Banmikeji.Settings_set_article_find(requestParams);

				this.find = ret.data.find;
				this.img_url = ret.img_url;
				this.content = ret.data.find.content
				this.is_true = true;



			}
		}
	}
</script>

<style lang="scss">

</style>